<?php
namespace app\api\home;

use clicaptcha\clicaptcha;
use app\common\controller\ApiBase;

/**
 * 防刷
**/
class Clicap extends ApiBase
{

    public function index(){
        $clicaptcha = new clicaptcha();
        $check = $this->request->post('do');
        if ($check === 'check'){
            $info = $this->request->post('info');
            if ($clicaptcha->check($info)){
                return rsJson([]);
            }
            return rsJson([],500);
        }
        $clicaptcha->creat();
    }

    public function getClicaptchaText(){
       return rsJson($_COOKIE['clicaptcha_text']);
    }
}